<?php

namespace App\Services\CategoryGroup;

use App\Models\Category;
use App\Models\CategoryGroup;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;

abstract class BaseCategoryGroup implements CategoryGroupInterface
{
    public function store(Request $request)
    {
        $request->validate($this->validate());

        Category::create($request->all());
    }

    public function update(Request $request, Category $category)
    {
        $request->validate($this->validate());

        $category->update($request->all());
    }

    public function validate()
    {
        return [
            'category_group' => ['required', 'string', Rule::in(Category::CATEGORY_GROUP)]
        ];
    }
}
